package com.mall.shopping.converter;

import com.mall.shopping.dal.entitys.Item;
import com.mall.shopping.dal.entitys.ShoppingCart;
import com.mall.shopping.dto.QueryGoodDto;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;

import java.util.List;

/**
 * @Author: lin
 * @Date: 2020/7/10 8:55
 */

@Mapper(componentModel = "spring")
public interface TbItemConverter {
    @Mappings({
            @Mapping(source = "id", target = "productId"),
            @Mapping(source = "price", target = "salePrice"),
            @Mapping(source = "title", target = "productName"),
            @Mapping(source = "sellPoint", target = "subTitle"),
            @Mapping(source = "imageBig", target = "picUrl")
    })
    QueryGoodDto QueryItem(Item item);

    List<QueryGoodDto> QueryItems(List<Item> items);

    @Mappings({
            @Mapping(source = "id", target = "productId"),
            @Mapping(source = "price", target = "salePrice"),
            @Mapping(source = "title", target = "productName"),
            @Mapping(source = "imageBig", target = "productImg")
    })
    ShoppingCart ItemToCart(Item item);

}
